
sort pik year
gen pred0_agiz = .
forvalues t=1/5 {
	reg parent_agiz i.l`t'.parent_agiz_bin##i.parent_maxage if inrange(year, 1994, 1995) | inrange(year, 1998, $max_parent_year)
	capture drop xxx
	predict xxx , xb
	gen predL`t'_agiz = xxx
	gen predL`t'_agiz_unadj = predL`t'_agiz*(cpi_jan/cpi_2015)
	replace pred0_agiz = xxx if year==1969+`t' | year==1974+`t' | year==1979+`t' | year==1984+`t' | year==1989+`t' | year==1994+`t'
save ${clean_data}/taxyrcut_parents, replace
}

gen pred_agiz = pred0_agiz
replace pred_agiz = parent_agiz if year==1969 | year==1974 | year==1979 | year==1984 | year==1989 | inrange(year, 1994, 1995) | inrange(year, 1998, $max_parent_year)

gen miss_pred_agiz =  pred_agiz==.
tab miss_pred_agiz

sum pred_agiz if year==1989, detail
sum pred_agiz if year==1990, detail

gen pred0_agiz_unadj = pred0_agiz*(cpi_jan/cpi_2015)
gen pred_agiz_unadj = pred_agiz*(cpi_jan/cpi_2015)

forvalues t=1/5 {
	gen i_agimissL`t' = (l`t'.parent_agiz==0)
	gen maxageL`t' = l`t'.parent_maxage
}

*Construct Percentile Income [This is a bit odd given its just the sample of parents]
foreach x in pred_agiz pred0_agiz parent_agiz {
	egen n`x' = count(`x'), by(year)
	egen r`x' = rank(`x') , by(year)
	gen p`x' = 100*r`x'/n`x'
	summ p`x', detail
	drop n`x' r`x'
}
